﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DATA.BusinessObjects;

namespace Presentation
{
    public partial class frmThayDoiHeSoLoaiKhach : Form
    {
        public frmThayDoiHeSoLoaiKhach()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmThayDoiQuiDinh2_Load(object sender, EventArgs e)
        {
            IList<Loaikhach> list_lk = LoaiKhachBUS.LayDanhSachLoaiKhach();

            cbxTenLoaiKhach.DataSource = list_lk;
            cbxTenLoaiKhach.DisplayMember = "TenLoaiKhach";
            cbxTenLoaiKhach.ValueMember = "Id";

            txtSoLuongKhachToiDaTrongPhong.Text = ThamSoBUS.LaySoLuongKhachToiDaMotPhong().ToString();
        }

        private void cbxTenLoaiKhach_SelectedIndexChanged(object sender, EventArgs e)
        {
            Loaikhach lk = (Loaikhach) cbxTenLoaiKhach.SelectedItem;
            txtHeSo.Text = lk.HeSo.ToString();
        }

        private void btnThayDoi_Click(object sender, EventArgs e)
        {
            Loaikhach lk = (Loaikhach)cbxTenLoaiKhach.SelectedItem;
            lk.HeSo = int.Parse(txtHeSo.Text);

            Thamso ts = ThamSoBUS.LayThamSo();
            ts.SoLuongKhachToiDaMotPhong = int.Parse(txtSoLuongKhachToiDaTrongPhong.Text);

            LoaiKhachBUS.CapNhatLoaiKhach(lk);
            ThamSoBUS.CapNhatThamSo(ts);

            MessageBox.Show("Đã thay đổi thành công");
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

    }
}
